package mylog

import (
	"github.com/gogf/gf/os/glog"
	"github.com/gogf/gf/os/gtime"
)

var LogPath = "./log"

func init() {
	err := glog.SetPath(LogPath)
	if err != nil {
		panic(err)
	}
	glog.SetFile("{Y-m-d H}.log")
}

func getLogger() *glog.Logger {
	return glog.Cat(gtime.Date())
}

func SetDebugMode(bl bool) {
	glog.SetDebug(bl)
}

func Debug(v ...interface{}) {
	getLogger().Async().Debug(v...)
}

func Debugf(format string, v ...interface{}) {
	getLogger().Async().Debugf(format, v...)
}

func Println(v ...interface{}) {
	getLogger().Async().Println(v...)
}

func Printf(format string, v ...interface{}) {
	getLogger().Async().Printf(format, v...)
}

func Fatal(v ...interface{}) {
	getLogger().Fatal(v...)
}

func Fatalf(format string, v ...interface{}) {
	getLogger().Fatalf(format, v...)
}

func Error(v ...interface{}) {
	getLogger().Async().Error(v...)
}

func Errorf(format string, v ...interface{}) {
	getLogger().Async().Errorf(format, v...)
}

func Panic(v ...interface{}) {
	getLogger().Panic(v...)
}

func Panicf(format string, v ...interface{}) {
	getLogger().Panicf(format, v...)
}
